package com.sgb.businessmodule.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.harisucici.jetpackbase.base.HBaseViewModel;
import com.sgb.businessmodule.BusinessConfig;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.view.countmenu.CountMenuEntity;

import java.util.List;

/**
 * @author 张驰
 * @date 2021/8/5 14:00
 * @Description 商机首页 model
 * @name HomeBusinessOpportunitiesModel
 */
public class HomeBusinessOpportunitiesModel extends HBaseViewModel {

    //首页顶部菜单栏数据
    public MutableLiveData<List<CountMenuEntity>> countMenuList = new MutableLiveData();

    public HomeBusinessOpportunitiesModel(@NonNull Application application) {
        super(application);
    }

    /*
     * 获取商机首页顶部菜单栏数据
     * */
    public void requestBusinessMenuData() {
        BusinessConfig.getInstance().getApi().getMenuData().enqueue(new ICallBack<BaseEntity<List<CountMenuEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CountMenuEntity>> data) {
                List<CountMenuEntity> list = data.getData();
                if (list.size() > 0) {
                    list.remove(0);
                }
                countMenuList.postValue(list);
            }
        });
    }
}
